<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view(TPL_FOLDER.'header');?>
<link rel="stylesheet" type="text/css" href="{root_path}js/jquery/hiAlert/jquery.hiAlerts.css">
<script type="text/javascript" src="{root_path}js/jquery/hiAlert/jquery.hiAlerts-min.js"></script>
<div id=left>
  <?php $this->load->view(TPL_FOLDER.'product_catalog_block');?>
  <?php $this->load->view(TPL_FOLDER.'contact_block');?>
</div>
<div id=right>
  <div class=art_list>
    <h3 class=blk_t><?php echo $nav_title;?></h3>
    <div id=sta_content>
      <table width="100%" border="0" cellspacing="0" cellpadding="5" class="ui-tx-top-tb">
        <tr>
          <td width="38%" align="center" valign="middle" class="ui-tx-s-border ui-tx-pic-box"><a href="<?php echo site_url(CTL_FOLDER.'product/pic_view/'.$product->id);?>" title="点击查看大图" target="_blank"><img src="{tpl_path}images/common/loading.gif" rel="<?php echo get_real_path($product->big_pic_path);?>" class="loading_250" /></a></td>
          <td width="62%"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="ui-tx-param-list">
              <tr>
                <th width="21%" align="left">产品名称：</th>
                <td width="79%"><?php echo $product->title;?></td>
              </tr>
              <tr>
                <th align="left">产品编号：</th>
                <td><?php echo $product->pNum;?></td>
              </tr>
              <tr>
                <th align="left">产品价格：</th>
                <td><?php echo format_curren($product->market_price);?></td>
              </tr>
              <tr>
                <th align="left">产品点击：</th>
                <td><?php echo $product->hits;?></td>
              </tr>
              <tr>
                <th align="left">上架时间：</th>
                <td><?php echo date('Y-m-d',$product->create_date);?></td>
              </tr>
              <tr>
                <th align="left">产品订购：</th>
                <td><input name="quantity" type="text" class="ui-tx-input" value="1" size="3" maxlength="8" />
                  <input type="button" value="购买" onclick="add_to_cart(<?php echo $product->id;?>)" class="ui-tx-button2" style="width:80px">
                </td>
              </tr>
            </table>
            <div class="ui-tx-share"><a href="<?php echo site_url(CTL_FOLDER.'product/pic_view/'.$product->id);?>" title="点击查看大图" target="_blank"> <img src="{tpl_path}images/common/zoom.jpg"  style="vertical-align:middle"/> 点击放大</a></div>
            <div class="ui-tx-share jq_ui_share"><a href="javascript:void(0)" title="分享给好友"> <img src="{tpl_path}images/common/share.jpg"  style="vertical-align:middle"/> 分享给好友</a>
              <div class="ui-tx-rss-div">链接：
                <input type="text" size="35" class="ui-tx-input" readonly="readonly" value="<?php echo site_url(CTL_FOLDER.'product/detail/'.$product->id);?>" onfocus="this.select()" onclick="this.select()" />
                <br />
                <br />
                <input type="button" onclick="js_copy('<?php echo site_url(CTL_FOLDER.'product/detail/'.$product->id);?>')" value="拷贝链接" style="width:70px; margin-left:35px" class="ui-tx-button2" />
              </div>
            </div></td>
        </tr>
      </table>
      <div class="ui-tx-tab-h">
        <ul>
          <li class="ui-tx-tab-h-active"><img src="{tpl_path}images/common/goreg_icon.jpg" style="vertical-align:middle" /> 产品描述</li>
        </ul>
      </div>
      <div class="clear"></div>
      <div class="ui-tx-product-content"><?php echo $product->content;?></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ui-tx-product-link">
        <tr>
          <td width="44%" align="left">上一个产品：<?php echo $content_link['prev'];?></td>
          <td width="12%" align="center"><a href="javascript:window.history.back()" title="点击返回">点击返回</a></td>
          <td width="44%" align="right">下一个产品：<?php echo $content_link['next'];?></td>
        </tr>
      </table>
    </div>
  </div>
</div>
<script language="javascript">
$(function(){
	$(".loading_250").each(function(){
		LoadImage($(this),$(this).attr("rel"),250);
	});
	$("div.jq_ui_share").mouseover(function(){
		var pos = $(this).offset();
		var l = pos.left;
		var t = pos.top;
		var div_w = $("div.ui-tx-rss-div").width();
		if((l+div_w) > d_width) l = (l - div_w);
		$(this).find("div.ui-tx-rss-div").css({left:(l-50),top:(t+28)}).show();
	});
	$("div.jq_ui_share").mouseout(function(){
		$(this).find("div.ui-tx-rss-div").hide();
	});
});
function add_to_cart(id)
{
	if (!is_numeric(id))
	{
		alert("订购的产品ID有误");
		return ;
	}
	var quantity=1;//初始化产品购买数量
	if(document.getElementById("quantity"))
	{
		quantity=document.getElementById("quantity").value;
	}
	if (!is_numeric(quantity))
	{
		alert("订购数量有误，请重新填写");
		return ;
	}
	hiOverAlert("<span id='showMsg'><img src='"+pic_loading_path+"' border='0' /> 数据处理中，请稍等...</span>",0);
	var success_msg="<p style='text-align:center;'>该产品已成功添加到购物车</p>";
	success_msg+="<p style='text-align:center;'><a href='<?php echo site_url(CTL_FOLDER.'order');?>'>[查看购物车]</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:CloseUi()'>[继续浏览]</a></p>";
	$.ajax({
		type: "POST",
		url: "<?php echo site_url(CTL_FOLDER.'order/add_to_cart');?>",
		data: "rd_id="+id+"&quantity="+quantity,
		success: function(msg){
			if(msg==1)
			{
				unhiOverAlert();
				hiBox(success_msg, '消息提示','300','','','');
			}
			else 
			{
				$("#showMsg").html("数据处理失败");
				setTimeout(function(){unhiOverAlert();}, 2000);
			}
		},
		error: function(data){
			$("#showMsg").html("数据处理失败");
			setTimeout(function(){unhiOverAlert();}, 2000);
		}
	}); 

}
</script>
<?php $this->load->view(TPL_FOLDER.'footer');?>
